DAX.do is a new website by SQLBI where you can write and run DAX queries over a sample Contoso database.
The goal of DAX.do is purely educational: if you are learning DAX or are merely curious to test a new DAX syntax, you now have a readily-available playground to do that. It does not require you to install any software. It does not even require a computer. If you suddenly feel the urge to test a new DAX idea, DAX.do also works on your mobile phone!
You frequently use DAX to write measures. However, testing a DAX measure requires a data model, a user interface, and a report. There is no easy and obvious way to test a DAX measure without a report. And you already have Power BI for that!
However, just with DAX.do, you can use the DAX query’s syntax to test a DAX measure without any report!
Hello, World!
Let us see some examples and go back to the basics: what is the equivalent of PRINT “Hello, world in DAX?
EVALUATE { "Hello, World!" }
If you want to test a measure, you embed it into a query. Here is a simple example:
DEFINE MEASURE 'Date'[My Time] = FORMAT ( NOW (), "hh:mm" ) EVALUATE { [My Time] }
Of course, you can also create business measures!
DEFINE MEASURE Sales[Margin %] = VAR Revenues = SUMX ( Sales, Sales[Quantity] * Sales[Net Price] ) VAR Cost = SUMX ( Sales, Sales[Quantity] * Sales[Unit Cost] ) VAR Margin = Revenues - Cost VAR Result = DIVIDE ( Margin, Revenues ) RETURN Result EVALUATE SUMMARIZECOLUMNS ( 'Product'[Brand], "Margin %", [Margin %] ) ORDER BY [Margin %] DESC
Did you notice the TRY IT button that appeared for previous queries? Follow the suggestion and try it! You can immediately see the result, change the DAX code, and execute it again.
Share your code
We initially built DAX.do for ourselves: we wanted an easy way to include sample DAX code in our articles. However, why keep it only for ourselves? If you have a blog, you can do the same!
The Share feature in DAX.do enables you to obtain a short URL that opens DAX.do with the DAX query you saved. The same dialog box also produces the CSS/HTML code to include both query and result in whatever piece you are writing.
What is next?
We do not expect to increase the number of features in DAX.do, but we are certainly going to integrate DAX.do into DAX Guide and in articles where the sample code can be executed over a standard model. Most of the articles will continue to have a sample PBIX file to download. However, topics related to DAX syntax and most of the examples in DAX Guide can use DAX queries to explain the use case of a function: DAX.do provides a safe environment to test the syntax quickly.
The development of DAX.do also opened up new ideas for tools we would like to have. For example, we would love to move the diagram view into a separate window that would remain visible while you write the DAX code in Power BI or DAX Studio. Multiple monitors, anyone? This is something that would be useful in any environment. Sounds interesting? It is without a doubt inspiring us for future tools that can help us be more productive.
But hey, these are thoughts for the future. For now, you can start playing with DAX.do.